package com.aliyun.oss.mapper;

import com.aliyun.oss.pojo.UserInfoPic;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserInfoPicMapper {

    @Update("UPDATE user JOIN user_info ON user.id = user_info.user_id SET user.password = #{password},user_info.nickname = #{nickname} WHERE `user`.id=#{userId};")
    void updateUserInfo(UserInfoPic userInfoPic);


    @Select("SELECT ui.*,u.username,u.password FROM user_info ui RIGHT JOIN user u ON ui.user_id = u.id WHERE user_id=#{id};")
    UserInfoPic getUserInfo(Object id);

    @Update("UPDATE user_info SET user_pic = #{upload} WHERE user_id = #{id};")
    void updateUserAvatar(Integer id, String upload);

    @Update("UPDATE user SET password = #{newPwd} WHERE id = #{id} AND password = #{oldPwd};")
    void updateUserPwd(Integer id, String newPwd, String oldPwd);
}
